package com.dtda.edu.miaosha.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.dtda.edu.miaosha.bo.UserInfoBo;
import com.dtda.edu.miaosha.common.exception.BaseExcpController;
import com.dtda.edu.miaosha.common.exception.BusinessException;
import com.dtda.edu.miaosha.common.response.EmBusinessError;
import com.dtda.edu.miaosha.common.response.ResponseType;
import com.dtda.edu.miaosha.service.UserService;

/**
 * @author 袁强
 * @version 2019年1月29日 上午11:21:52
 * 类说明  
 */
@RestController
@RequestMapping("/")
public class TestController extends BaseExcpController{

	@Autowired
	private UserService userService;
	@RequestMapping("/get")
	@ResponseBody
	public ResponseType login(@RequestParam Integer id) throws BusinessException {
		 
		UserInfoBo userInfoBo = userService.getUserById(id);
		if(userInfoBo == null) {
			throw new BusinessException(EmBusinessError.USER_NOT_EXIST);
		}
		return ResponseType.create(userInfoBo);
	}
	@RequestMapping("/bootstrap")
	public ModelAndView bootstrap() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("project/ceshi");
		return modelAndView;
	}
}
